package com.jinmdz.fmis.api.rec.controller;

import com.jinmdz.fmis.api.api.model.common.IdData;
import com.jinmdz.fmis.api.api.model.common.IdVersionData;
import com.jinmdz.fmis.api.base.BaseController;
import com.jinmdz.fmis.api.model.config.ConfigData;
import com.jinmdz.fmis.api.rec.model.recinfo.RecInfoAllRequestData;
import com.jinmdz.fmis.api.rec.model.recinfo.RecInfoData;
import com.jinmdz.fmis.api.rec.service.RecInfoService;
import com.jinmdz.fmis.core.base.BaseResult;
import com.jinmdz.fmis.dao.model.recinfo.RecInfoSearh;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zhanglr
 * @date 2020-6-10 11:23
 */
@Api(description = "车辆调度电话接运信息相关接口")
@RestController()
@RequestMapping("/rec/rec_info/")
public class RecInfoController extends BaseController {

    @Resource
    private ConfigData configData;

    @Autowired
    private RecInfoService recInfoService;

    /**
     * 保存车辆调度信息到dispatch_car表中
     *
     * @param
     * @return
     * @author ZhangLiRui
     * @date 2020-6-10 17:22
     */
    @ApiOperation(value = "保存接运任务信息到rec_info表中", notes = "保存接运任务信息到rec_info表中")
    @PostMapping("save-rec-info")
    public BaseResult saveRecInfo(@RequestBody RecInfoData data) {
        return resultHandler(data, userItem -> recInfoService.saveRecInfo(userItem, data));
    }

    /**
     * 保存调度车辆信息，并将车辆接运信息【预约登记】->【已调度】
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-06-16
     */
    @ApiOperation(value = "保存调度车辆信息，并将车辆接运信息【预约登记】->【已调度】", notes = "保存调度车辆信息，并将车辆接运信息【预约登记】->【已调度】")
    @PostMapping("save-rec-info-dispatch")
    public BaseResult saveRecInfoDispatch(@RequestBody RecInfoData data) {
        return resultHandler(data, userItem -> recInfoService.confirmDispatchCar(userItem, data));
    }

    /**
     * 从rec_info表中删除指定id的接运任务信息
     *
     * @param
     * @return
     * @author ZhangLiRui
     * @date 2020-6-11 11:42
     */
    @ApiOperation(value = "从rec_info表中删除指定id的接运任务信息", notes = "从rec_info表中删除指定id的接运任务信息")
    @PostMapping("delete-rec-info-with-id")
    public BaseResult deleteRecInfowithId(@RequestBody IdVersionData data) {
        return resultHandler(data, userItem -> recInfoService.deleteRecInfowithId(userItem, data));
    }

    /**
     * 根据rec_info表中id加载接运信息
     *
     * @param data
     * @return
     * @author ZhangLiRui
     * @date 2020-6-12 9:45
     */
    @ApiOperation(value = "根据rec_info表中id加载接运信息", notes = "根据rec_info表中id加载接运信息")
    @PostMapping("load-rec-info-with-id")
    public BaseResult loadRecInfoWithId(@RequestBody IdData data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoWithId(data));
    }

    /**
     * 根据rec_info表中id加载接运打印二维码数据
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-06-16
     */
    @ApiOperation(value = "根据rec_info表中id加载接运打印二维码数据", notes = "根据rec_info表中id加载接运打印二维码数据")
    @PostMapping("load-rec-info-print-code-with-id")
    public BaseResult loadRecInfoPrintCodeWithId(@RequestBody IdData data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoPrintCodeWithId(data));
    }

    /**
     * 根据rec_info表中id加载接运派车单数据
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-06-16
     */
    @ApiOperation(value = "根据rec_info表中id加载接运派车单数据", notes = "根据rec_info表中id加载接运派车单数据")
    @PostMapping("load-rec-info-print-trucking-order-with-id")
    public BaseResult loadRecInfoPrintTruckingOrderWithId(@RequestBody IdData data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoPrintTruckingOrderWithId(data));
    }

    /**
     * 根据rec_info表中id加载接运信息
     *
     * @param data
     * @return
     * @author ZhangLiRui
     * @date 2020-6-12 9:45
     */
    @ApiOperation(value = "接运信息，界面权限验证及基础数据加载", notes = "接运信息，界面权限验证及基础数据加载")
    @PostMapping("load-rec-info-all")
    public BaseResult loadRecInfoAll(@RequestBody RecInfoAllRequestData data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoAll(data));
    }

    /**
     * 根据rec_info表中id加载接运信息
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-12 9:45
     */
    @ApiOperation(value = "接运信息，界面权限验证及基础数据加载", notes = "接运信息，界面权限验证及基础数据加载")
    @PostMapping("load-rec-info-wx-all")
    public BaseResult loadRecInfoWXAll(@RequestBody RecInfoAllRequestData data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoWXAll(data));
    }

    /**
     * 获得指定日期和appId号的接运信息列表
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-12 9:45
     */
    @ApiOperation(value = "获得指定日期和appId号的接运信息列表", notes = "获得指定日期和appId号的接运信息列表")
    @PostMapping("load-rec-info-wx-all-list-by-app-id")
    public BaseResult loadRecInfoWXAllListByAppId(@RequestBody RecInfoSearh data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoWXAllListByAppId(data));
    }

    /**
     * 通过日期和appId号查询微信用户接运信息车辆的轨迹点
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-12 9:45
     */
    @ApiOperation(value = "通过日期和appId号查询微信用户接运信息车辆的轨迹点", notes = "通过日期和appId号查询微信用户接运信息车辆的轨迹点")
    @PostMapping("load-rec-info-wx-track-by-rec-code")
    public BaseResult loadRecInfoWXTrackByRecCode(@RequestBody RecInfoSearh data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoWXTrackByRecCode(data));
    }

    /**
     * 加载微信对话框物品
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-12 9:45
     */
    @ApiOperation(value = "加载微信对话框物品", notes = "加载微信对话框物品")
    @PostMapping("load-rec-info-wx-dialog-service-items")
    public BaseResult loadRecInfoWXDialogServiceItems(@RequestBody RecInfoAllRequestData data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoWXDialogServiceItems(data));
    }

    /**
     * App接运登记，数据验证及基础数据加载
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-12 9:45
     */
    @ApiOperation(value = "App接运登记，数据验证及基础数据加载", notes = "App接运登记，数据验证及基础数据加载")
    @PostMapping("load-rec-info-app-all")
    public BaseResult loadRecInfoAppAll(@RequestBody RecInfoAllRequestData data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoAll(data));
    }

    /**
     * App接运登记,添加随车物品的接口
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-22 14:45
     */
    @ApiOperation(value = "App接运登记,添加随车物品的接口", notes = "App接运登记,添加随车物品的接口")
    @PostMapping("load-rec-info-app-dialog-service-items")
    public BaseResult loadRecInfoAppDialogServiceItems(@RequestBody RecInfoAllRequestData data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoWXDialogServiceItems(data));
    }

    /**
     * App端获得指定日期的接运信息列表
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-22 16:45
     */
    @ApiOperation(value = "App端获得指定日期的接运信息列表", notes = "App端获得指定日期的接运信息列表")
    @PostMapping("load-rec-info-app-all-list")
    public BaseResult loadRecInfoAppAllList(@RequestBody RecInfoSearh data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoWXAllListByAppId(data));
    }

    /**
     * App端获得指定日期的未完成接运信息列表
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-22 16:45
     */
    @ApiOperation(value = "App端获得指定日期的未完成接运信息列表", notes = "App端获得指定日期的未完成接运信息列表")
    @PostMapping("load-rec-info-app-not-finish-list")
    public BaseResult loadRecInfoAppNotFinishList(@RequestBody RecInfoSearh data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoAppNotFinishList(data));
    }

    /**
     * app端获得指定日期和imei号的接运轨迹列表对象
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-22 16:45
     */
    @ApiOperation(value = "app端获得指定日期和imei号的接运轨迹列表对象", notes = "app端获得指定日期和imei号的接运轨迹列表对象")
    @PostMapping("load-rec-info-app-track-by-rec-code")
    public BaseResult loadRecInfoAppTrackByRecCode(@RequestBody RecInfoSearh data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoWXTrackByRecCode(data));
    }

    /**
     * CS端根据rec_info表中id加载接运信息
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-22 17:35
     */
    @ApiOperation(value = "CS端根据rec_info表中id加载接运信息", notes = "CS端根据rec_info表中id加载接运信息")
    @PostMapping("load-rec-info-cs-out-car-with-id")
    public BaseResult loadRecInfoCsOutCarWithId(@RequestBody RecInfoAllRequestData data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoAll(data));
    }

    /**
     * CS端根据rec_info表中id加载接运信息
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-22 17:35
     */
    @ApiOperation(value = "CS端根据rec_info表中id加载接运信息", notes = "CS端根据rec_info表中id加载接运信息")
    @PostMapping("load-rec-info-cs-back-car-with-id")
    public BaseResult loadRecInfoCsBackCarWithId(@RequestBody RecInfoAllRequestData data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoAll(data));
    }

    /**
     * 更新接运信息到rec_info表中，接运状态由预约状态->确认出车状态
     *
     * @param
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-22 17:42
     */
    @ApiOperation(value = "更新接运信息到rec_info表中，接运状态由预约状态->确认出车状态", notes = "更新接运信息到rec_info表中，接运状态由预约状态->确认出车状态")
    @PostMapping("confirm-rec-info-app-out-car")
    public BaseResult confirmRecInfoAppOutCar(@RequestBody RecInfoData data) {
        return resultHandler(data, userItem -> recInfoService.confirmRecInfoAppOutCar(userItem, data));
    }

    /**
     * 更新接运信息到rec_info表中，接运状态由出车确认状态->已完成状态
     *
     * @param
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-22 17:42
     */
    @ApiOperation(value = "更新接运信息到rec_info表中，接运状态由出车确认状态->已完成状态", notes = "更新接运信息到rec_info表中，接运状态由出车确认状态->已完成状态")
    @PostMapping("confirm-rec-info-app-back-car")
    public BaseResult confirmRecInfoAppBackCar(@RequestBody RecInfoData data) {
        return resultHandler(data, userItem -> recInfoService.confirmRecInfoAppBackCar(userItem, data));
    }

    /**
     * CS端更新接运信息到rec_info表中，接运状态由预约状态->确认出车状态
     *
     * @param
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-22 17:42
     */
    @ApiOperation(value = "更新接运信息到rec_info表中，接运状态由预约状态->确认出车状态", notes = "更新接运信息到rec_info表中，接运状态由预约状态->确认出车状态")
    @PostMapping("confirm-rec-info-cs-out-car")
    public BaseResult confirmRecInfoCsOutCar(@RequestBody RecInfoData data) {
        return resultHandler(data, userItem -> recInfoService.confirmRecInfoAppOutCar(userItem, data));
    }

    /**
     * CS端更新接运信息到rec_info表中，接运状态由出车确认状态->已回车状态
     *
     * @param
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-22 17:42
     */
    @ApiOperation(value = "更新接运信息到rec_info表中，接运状态由出车确认状态->已完成状态", notes = "更新接运信息到rec_info表中，接运状态由出车确认状态->已完成状态")
    @PostMapping("confirm-rec-info-cs-back-car")
    public BaseResult confirmRecInfoCsBackCar(@RequestBody RecInfoData data) {
        return resultHandler(data, userItem -> recInfoService.confirmRecInfoAppBackCar(userItem, data));
    }

    /**
     * CS端加载车辆调度信息列表，带分页
     *
     * @param data
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-22 16:45
     */
    @ApiOperation(value = "CS端加载车辆调度信息列表，带分页", notes = "CS端加载车辆调度信息列表，带分页")
    @PostMapping("load-rec-info-cs-all-by-page")
    public BaseResult loadRecInfoCsAllByPage(@RequestBody RecInfoSearh data) {
        return resultHandler(data, userItem -> recInfoService.loadRecInfoCsAllByPage(data));
    }
}
